package com.gopay.common.cps.dao.bt.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.bt.CpsGainCalJobInfoDAO;
import com.gopay.common.domain.cps.CpsGainsCalJobInfo;

/**
 * @CpsGainCalJobInfoDAOImpl.java
 * @author wanggang
 * @2013-8-14 下午5:48:29  www.gopay.com.cn Inc.All rights reserved.
 */
@Repository("cpsGainCalJobInfoDAO")
public class CpsGainCalJobInfoDAOImpl extends BaseDAOImpl<CpsGainsCalJobInfo, Serializable> implements CpsGainCalJobInfoDAO{

	@Override
	public List<CpsGainsCalJobInfo> getEarningsJob(String date,int pageNo,int size) {
		Map m = new HashMap();
		m.put("jobStartDate", date);
		return this.findByHql("from CpsGainsCalJobInfo s where s.jobStartDate<=:jobStartDate",m, pageNo,size);
	}
	@Override
	public int getEarningsJobCount(String date) {
		Map m = new HashMap();
		m.put("jobStartDate", date);
		int count =findCountBySql("from CPS_GAINS_CAL_JOB_INFO s where s.JOB_START_DATE<=:jobStartDate",m);
		return count;
	}
    @Override
    public CpsGainsCalJobInfo getCpsGainsCalJobInfoByAcctId(String acctId) {
        DetachedCriteria criteria = DetachedCriteria.forClass(CpsGainsCalJobInfo.class);
        criteria.add(Restrictions.eq("acctId",acctId));
        List<CpsGainsCalJobInfo> list = this.findByCriteria(criteria);
        return list.size()>0 ? list.get(0): null;
    }

}
